home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / java / creator changer / creator changer project / source / resultsdialog.java < prev    next >
Encoding:
Java Source  |  2000-06-23  |  5.3 KB  |  218 lines

  1. import java.awt.*;
  2. import java.awt.event.KeyEvent;
  3.  
  4. public class ResultsDialog extends Dialog
  5. {
  6.     public ResultsDialog(Frame parent)
  7.     {
  8.         super(parent, true);
  9.  
  10.         // This code is automatically generated by Visual Cafe when you add
  11.         // components to the visual environment. It instantiates and initializes
  12.         // the components. To modify the code, only use code syntax that matches
  13.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  14.         // parse your Java file into its visual environment.
  15.         //{{INIT_CONTROLS
  16.         GridBagLayout gridBagLayout;
  17.         gridBagLayout = new GridBagLayout();
  18.         setLayout(gridBagLayout);
  19.         setVisible(false);
  20.         setSize(365,121);
  21.         setBackground(new Color(-1644826));
  22.         label2 = new java.awt.Label("text");
  23.         label2.setBounds(52,35,25,25);
  24.         GridBagConstraints gbc;
  25.         gbc = new GridBagConstraints();
  26.         gbc.gridx = 1;
  27.         gbc.gridy = 1;
  28.         gbc.gridwidth = 2;
  29.         gbc.weightx = 1.0;
  30.         gbc.anchor = GridBagConstraints.NORTHWEST;
  31.         gbc.fill = GridBagConstraints.NONE;
  32.         gbc.insets = new Insets(0,0,0,0);
  33.         ((GridBagLayout)getLayout()).setConstraints(label2, gbc);
  34.         add(label2);
  35.         label3 = new java.awt.Label("text");
  36.         label3.setBounds(52,60,25,25);
  37.         gbc = new GridBagConstraints();
  38.         gbc.gridx = 1;
  39.         gbc.gridy = 2;
  40.         gbc.gridwidth = 2;
  41.         gbc.weightx = 1.0;
  42.         gbc.anchor = GridBagConstraints.NORTHWEST;
  43.         gbc.fill = GridBagConstraints.NONE;
  44.         gbc.insets = new Insets(0,0,0,0);
  45.         ((GridBagLayout)getLayout()).setConstraints(label3, gbc);
  46.         add(label3);
  47.         defaultBorder1 = new DefaultBorder();
  48.         defaultBorder1.setBounds(294,82,64,26);
  49.         gbc = new GridBagConstraints();
  50.         gbc.gridx = 3;
  51.         gbc.gridy = 3;
  52.         gbc.fill = GridBagConstraints.NONE;
  53.         gbc.insets = new Insets(0,0,10,10);
  54.         ((GridBagLayout)getLayout()).setConstraints(defaultBorder1, gbc);
  55.         okButton = new java.awt.Button();
  56.         okButton.setLabel("OK");
  57.         okButton.setBounds(3,3,58,20);
  58.         defaultBorder1.add(okButton);
  59.         add(defaultBorder1);
  60.  
  61.         label1 = new java.awt.Label("text");
  62.         label1.setBounds(52,10,25,25);
  63.         gbc = new GridBagConstraints();
  64.         gbc.gridx = 1;
  65.         gbc.gridy = 0;
  66.         gbc.gridwidth = 2;
  67.         gbc.weightx = 1.0;
  68.         gbc.anchor = GridBagConstraints.NORTHWEST;
  69.         gbc.fill = GridBagConstraints.NONE;
  70.         gbc.insets = new Insets(10,0,0,0);
  71.         ((GridBagLayout)getLayout()).setConstraints(label1, gbc);
  72.         add(label1);
  73.         imageComponent1 = new ImageComponent();
  74.         imageComponent1.setBounds(10,10,32,32);
  75.         imageComponent1.setImage(Util.loadImage("images/info.gif", this));
  76.         gbc = new GridBagConstraints();
  77.         gbc.gridx = 0;
  78.         gbc.gridy = 0;
  79.         gbc.gridheight = 3;
  80.         gbc.anchor = GridBagConstraints.NORTHWEST;
  81.         gbc.fill = GridBagConstraints.NONE;
  82.         gbc.insets = new Insets(10,10,0,10);
  83.         ((GridBagLayout)getLayout()).setConstraints(imageComponent1, gbc);
  84.         add(imageComponent1);
  85.         setTitle("Done Processing...");
  86.         setResizable(false);
  87.         //}}
  88.  
  89.         //{{REGISTER_LISTENERS
  90.         SymWindow aSymWindow = new SymWindow();
  91.         this.addWindowListener(aSymWindow);
  92.         SymAction lSymAction = new SymAction();
  93.         okButton.addActionListener(lSymAction);
  94.         SymKey aSymKey = new SymKey();
  95.         this.addKeyListener(aSymKey);
  96.         imageComponent1.addKeyListener(aSymKey);
  97.         label1.addKeyListener(aSymKey);
  98.         label2.addKeyListener(aSymKey);
  99.         label3.addKeyListener(aSymKey);
  100.         okButton.addKeyListener(aSymKey);
  101.         defaultBorder1.addKeyListener(aSymKey);
  102.         //}}
  103.     }
  104.     
  105.     public void setLabel1(String text)
  106.     {
  107.         label1.setText(text);
  108.     }
  109.     
  110.     public String getLabel1()
  111.     {
  112.         return label1.getText();
  113.     }
  114.  
  115.     public void setLabel2(String text)
  116.     {
  117.         label2.setText(text);
  118.     }
  119.     
  120.     public String getLabel2()
  121.     {
  122.         return label2.getText();
  123.     }
  124.  
  125.     public void setLabel3(String text)
  126.     {
  127.         label3.setText(text);
  128.     }
  129.     
  130.     public String getLabel3()
  131.     {
  132.         return label3.getText();
  133.     }
  134.     
  135.     /**
  136.      * Shows or hides the component depending on the boolean flag b.
  137.      * @paramLabel b  if true, show the component; otherwise, hide the component.
  138.      * @see java.awt.Component#isVisible
  139.      */
  140.     public void setVisible(boolean b)
  141.     {
  142.         if(b)
  143.         {
  144.             Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
  145.             Dimension dSize = getSize();
  146.     
  147.             setLocation((sSize.width - dSize.width) >> 1, (int)(0.33333333 * sSize.height));
  148.             Toolkit.getDefaultToolkit().beep();
  149.         }
  150.         super.setVisible(b);
  151.     }
  152.  
  153.     public void update(Graphics g)
  154.     {
  155.         paint(g);
  156.     }
  157.  
  158.     public void close()
  159.     {
  160.         // Hide the Dialog
  161.         setVisible(false);
  162.         dispose();
  163.     }
  164.     
  165.     //{{DECLARE_CONTROLS
  166.     java.awt.Label label2;
  167.     java.awt.Label label3;
  168.     java.awt.Button okButton;
  169.     java.awt.Label label1;
  170.     ImageComponent imageComponent1;
  171.     DefaultBorder defaultBorder1;
  172.     //}}
  173.  
  174.     class SymWindow extends java.awt.event.WindowAdapter
  175.     {
  176.         public void windowClosing(java.awt.event.WindowEvent event)
  177.         {
  178.             Object object = event.getSource();
  179.             if (object == ResultsDialog.this)
  180.                 ResultsDialog_WindowClosing(event);
  181.         }
  182.     }
  183.     
  184.     void ResultsDialog_WindowClosing(java.awt.event.WindowEvent event)
  185.     {
  186.         close();
  187.     }
  188.  
  189.     class SymAction implements java.awt.event.ActionListener
  190.     {
  191.         public void actionPerformed(java.awt.event.ActionEvent event)
  192.         {
  193.             Object object = event.getSource();
  194.             if (object == okButton)
  195.                 okButton_ActionPerformed(event);
  196.         }
  197.     }
  198.  
  199.     void okButton_ActionPerformed(java.awt.event.ActionEvent event)
  200.     {
  201.         close();
  202.     }
  203.  
  204.     class SymKey extends java.awt.event.KeyAdapter
  205.     {
  206.         public void keyPressed(java.awt.event.KeyEvent event)
  207.         {
  208.             handleKeyPressed(event);
  209.         }
  210.     }
  211.  
  212.     void handleKeyPressed(java.awt.event.KeyEvent event)
  213.     {
  214.         if (event.getKeyCode() == KeyEvent.VK_ENTER)
  215.             close();
  216.     }
  217. }
  218.